<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
	<title>Test Ajax JS</title>
	<!-- INCLUDE JS FILES - ALWAYS HttpClient.js and Element.js, for Invoice, Recurring and Estimate include BaseInvoice.js as well -->
	<script language="javascript" type="text/javascript" src="library/FreshBooks/HttpClient.js"></script>
	<script language="javascript" type="text/javascript" src="library/FreshBooks/Element.js"></script>
	<script language="javascript" type="text/javascript" src="library/FreshBooks/Client.js"></script>
	<!-- helper js, defines dump() function similar to php print_r()  -->
	<script language="javascript" type="text/javascript" src="library/dumper.js"></script>
	<script language="javascript" type="text/javascript">
	//<!--
	//you API url and token obtained from freshbooks.com
	var url = 'your-url-please-replace';
	var token = 'your-token-please-replace';
	//proxy server script - if your server doesn't support php try creating similar file in supported server side technology
	var proxyUrl = 'proxy.php';
	//init global FreshBooks_HttpClient
	var httpClient = new FreshBooks_HttpClient(url,token,proxyUrl);
	
	function getClient(){
		//new Client object
		var client = new FreshBooks_Client();
		//try to get client with client_id 1
		if(client.get(1)){
			//investigate populated data
			document.getElementById('response').value = dump(client);
		}
		else{
			//no data - read error
			document.getElementById('response').value = client.lastError;
		}
	}
	//-->
	</script>
</head>
<body>
	<h1>FreshBooks API js library Example</h1>
	<input type="button" name="test" id="test" value="Get Client ID 1" onclick="getClient();" />
	<textarea id="response" name="response" rows="5" cols="60" style="width:100%; height: 300px;"></textarea>	
</body>
</html>